package com.tanhua.recommend.job;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Set;

@Component
public class PeachblossomJob {

    @Autowired
    private StringRedisTemplate redisTemplate;

//    @Scheduled(cron = "0 0 0 0/1 * ?")每天零点刷新
    @Scheduled(cron = "0 0/3 * * * ?")//测试
    public void saveRecommend(){

        //获取redis所有的key值    统一清除
        Set<String> keys = redisTemplate.keys("userSound_*");

        for (String key : keys) {
            redisTemplate.delete(key);
        }
    }
}
